{% extends "custom_admin/base.html" %}

{% block title %}
{% if permission_group %}编辑权限组{% else %}创建权限组{% endif %}
{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">{% if permission_group %}编辑权限组{% else %}创建权限组{% endif %}</h1>
</div>

<div class="row">
    <div class="col-md-8">
        <form method="post">
            {% csrf_token %}
            
            <div class="mb-3">
                <label for="{{ form.name.id_for_label }}" class="form-label">权限组名称</label>
                {{ form.name }}
                {% if form.name.errors %}
                <div class="text-danger">{{ form.name.errors }}</div>
                {% endif %}
            </div>
            
            <div class="mb-3">
                <label for="{{ form.code.id_for_label }}" class="form-label">权限组编码</label>
                {{ form.code }}
                {% if form.code.errors %}
                <div class="text-danger">{{ form.code.errors }}</div>
                {% endif %}
            </div>
            
            <div class="mb-3">
                <label for="{{ form.description.id_for_label }}" class="form-label">描述</label>
                {{ form.description }}
                {% if form.description.errors %}
                <div class="text-danger">{{ form.description.errors }}</div>
                {% endif %}
            </div>
            
            <div class="mb-3">
                <label for="{{ form.permissions.id_for_label }}" class="form-label">权限列表</label>
                {{ form.permissions }}
                {% if form.permissions.errors %}
                <div class="text-danger">{{ form.permissions.errors }}</div>
                {% endif %}
            </div>
            
            <div class="mb-3 form-check">
                {{ form.is_active }}
                <label for="{{ form.is_active.id_for_label }}" class="form-check-label">启用</label>
                {% if form.is_active.errors %}
                <div class="text-danger">{{ form.is_active.errors }}</div>
                {% endif %}
            </div>
            
            <div class="mb-3">
                <button type="submit" class="btn btn-primary">保存</button>
                <a href="{% url 'custom_admin:permission_group_list' %}" class="btn btn-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}